#ifndef __QSINGLETON_H__
#define __QSINGLETON_H__

#include <pthread.h>

template<class T>
class qSingleton
{
protected:
    qSingleton(){};
    ~qSingleton(){};

public:
    qSingleton(const qSingleton&) = delete;
    qSingleton& operator=(const qSingleton&) = delete;

    static T* getInstance()
    {
        return &singlton_;
    }

    static void delInstance()
    {
        
    }

private:
    static T singlton_;
};

template<class T>
T qSingleton<T>::singlton_;


class qMutex
{
public:
	qMutex()
	{
		pthread_mutex_init(&mt_, nullptr);
	}

	~qMutex()
	{
		pthread_mutex_destroy(&mt_);
	}

	void lock()
	{
		pthread_mutex_lock(&mt_);
	}

	void unlock()
	{
		pthread_mutex_unlock(&mt_);
	}
private:
	pthread_mutex_t mt_;
};

#endif